package com.isesol.ime.service;

import com.google.common.collect.*;
import com.isesol.ime.dal.mapper.*;
import com.isesol.ime.util.*;
import lombok.extern.slf4j.*;
import org.springframework.stereotype.*;

import javax.annotation.*;
import java.util.*;

import static com.isesol.ime.Constant.*;

/**
 * 参数类别
 *
 * @author peter zhang
 */
@Component
@Slf4j
public class CategoryService{

	@Resource
	CategoryMapper categoryMapper;

	/**
	 * 获取所有参数类别
	 *
	 * @return
	 */
	public Map findAll(){

		Map result = (Map) CacheUtil.get(CACHE_KEY_CATEGORY);

		if (null != result){

			return result;
		}

		Map m = Maps.newHashMap();

		m.put("items", categoryMapper.findAll());

		CacheUtil.put(CACHE_KEY_CATEGORY, m);

		return m;
	}

}
